package com.wsoft.hr.pm.manager;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wsoft.core.service.RedisService;
import com.wsoft.hr.pm.entity.HrPmTemplateTargetEntity;
import com.wsoft.hr.pm.mapper.HrPmTemplateTargetMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author z001
 * @Date 2025年02月17日 15:06:35
 */
@Slf4j
@Service
public class HrPmTemplateTargetManager extends ServiceImpl<HrPmTemplateTargetMapper, HrPmTemplateTargetEntity> {

    @Resource
    private RedisService redisService;


    /**
     * 查询 维度下的 指标
     * @param scopeIdList
     * @return
     */
    public List<HrPmTemplateTargetEntity> getByScopeIds(List<Long> scopeIdList) {
        if(CollUtil.isEmpty(scopeIdList)){
            return new ArrayList<>();
        }
        QueryWrapper<HrPmTemplateTargetEntity> query = new QueryWrapper<>();
        query.lambda().in(HrPmTemplateTargetEntity::getScopeId,scopeIdList);
        return list(query);
    }


    /**
     * 根据 targetHisId 查询
     * @param targetHisId
     * @return
     */
    public HrPmTemplateTargetEntity getTemplateTargetHisId(Long targetHisId) {
        QueryWrapper<HrPmTemplateTargetEntity> query = new QueryWrapper<>();
        query.lambda().eq(HrPmTemplateTargetEntity::getTemplateTargetHisId,targetHisId);
        return getOne(query);
    }
}
